package com.business.socialcredit;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.frame.struts.BaseBean;
import com.utils.CommUtil;
import com.utils.DateConverter;

public class SfzxjlForm extends BaseBean
{
    public SfzxjlForm()
    {
    }
    
    static{
        ConvertUtils.register(new DateConverter(), Date.class);
    }

    SfzxjlEntity sfzxjlEntity = new SfzxjlEntity();
    private String oldId="";

    public String addSfzxjl()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addSfzxjl()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        sfzxjlEntity.setQyid( qyid );
        sfzxjlEntity.setOptdate( new Date() );
        sfzxjlEntity.setOptrid( CommUtil.getUserId( request ) );
        sfzxjlEntity.setXh( SocialCreditFactory.getNextXh( "qy_sfzxjl", qyid ) );
        try
        {
            if( factory.addSfzxjl( sfzxjlEntity ) )
            {
                System.out.println( "Enter addSfzxjl()" );
                response.sendRedirect( "/socialcredit/querysfzxjl.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
        }
        return null;

    }

    public String editSfzxjl()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addSfzxjl()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        sfzxjlEntity.setQyid( qyid );
        sfzxjlEntity.setOptdate( new Date() );
        sfzxjlEntity.setOptrid( CommUtil.getUserId( request ) );
        factory.delSfzxjl(qyid,sfzxjlEntity.getXh());
        try
        {
            if( factory.addSfzxjl( sfzxjlEntity ) )
            {
                System.out.println( "Enter editSfzxjl()" );
                response.sendRedirect( "/socialcredit/querysfzxjl.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return null;
    }
    
    public String getOldId(){
        return this.oldId;
    }
    public void setOldId(String oldId){
        this.oldId=oldId;
    }
    
    public String getQyid()
    {
        return sfzxjlEntity.getQyid();
    }

    public void setQyid( String qyid )
    {
        sfzxjlEntity.setQyid(qyid);
    }

    public int getXh()
    {
        return sfzxjlEntity.getXh();
    }

    public void setXh( int xh )
    {
        sfzxjlEntity.setXh( xh );
    }

    public String getZxyy()
    {
        return sfzxjlEntity.getZxyy();
    }

    public void setZxyy( String zxyy )
    {
        sfzxjlEntity.setZxyy( zxyy );
    }

    public String getZxfs()
    {
        return sfzxjlEntity.getZxfs();
    }

    public void setZxfs( String zxfs )
    {
        sfzxjlEntity.setZxfs( zxfs );
    }

    public java.sql.Date getZxrq()
    {
        return sfzxjlEntity.getZxrq();
    }

    public void setZxrq( java.sql.Date zxrq )
    {
        sfzxjlEntity.setZxrq( zxrq );
    }

    public String getZxjg()
    {
        return sfzxjlEntity.getZxjg();
    }

    public void setZxjg( String zxjg )
    {
        sfzxjlEntity.setZxjg( zxjg );
    }
    
    public String getOptrid()
    {
        return sfzxjlEntity.getOptrid();
    }

    public void setOptrid( String optrid )
    {
        sfzxjlEntity.setOptrid( optrid );
    }

    public Date getOptdate()
    {
        return sfzxjlEntity.getOptdate();
    }

    public void setOptdate( Date optdate )
    {
        sfzxjlEntity.setOptdate( optdate );
    }

    public String getRecstate()
    {
        return sfzxjlEntity.getRecstate();
    }

    public void setRecstate( String recstate )
    {
        sfzxjlEntity.setRecstate( recstate );
    }

    public String getRemark()
    {
        return sfzxjlEntity.getRemark();
    }

    public void setRemark( String remark )
    {
        sfzxjlEntity.setRemark( remark );
    }

}
